package com.code.apollo.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * <Description>
 * 配置文件工具类
 * @author Jun Lee
 * @version 1.0
 * @createDate 2020/03/16 11:32
 * @see com.code.apollo.utils
 */
public class PropUtil {
    public static Map<String,String> customMap = new HashMap<>();

    static {
        File file = new File(Thread.currentThread()
                .getContextClassLoader().getResource("properties").getPath());
        for (File prop : file.listFiles()) {
            if (prop.getName().endsWith(".properties")) {
                Properties properties = new Properties();
                try {
                    properties.load(new FileInputStream(prop));
                    customMap.putAll((Map)properties);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
